{extend name="common:base" /}
{block name="body"}
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="image" class="layui-form-label">桌面端
                </label>
                <div class="layui-input-inline">
                    <button class="layui-btn" type="button"
                        onclick="xadmin.open('选择图片','{:url(\'media_select_image\',[\'path\'=>\'images\/\',\'class\'=>\'desktop\'])}')">
                        <i class="layui-icon"></i>选择
                    </button>
                    <div class="desktop" style="height: 92px;padding-top: 5px">
                        {notempty name="data.desktop"}
                        <img src="{$data.desktop}" alt="" style="height: 92px">
                        <input type="hidden" name="desktop" value="{$data.desktop}" id="desktop">
                        {else /}
                        <img src="" alt="" style="height: 92px">
                        <input type="hidden" name="desktop" value="" id="desktop">
                        {/notempty}
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="image" class="layui-form-label">移动端
                </label>
                <div class="layui-input-inline">
                    <button class="layui-btn" type="button"
                        onclick="xadmin.open('选择图片','{:url(\'media_select_image\',[\'path\'=>\'images\/\',\'class\'=>\'mobile\'])}')">
                        <i class="layui-icon"></i>选择</button>
                    <div class="mobile" style="height: 92px;padding-top: 5px">
                        {notempty name="data.mobile"}
                        <img src="{$data.mobile}" alt="" style="height: 92px">
                        <input type="hidden" name="mobile" value="{$data.mobile}" id="mobile">
                        {else /}
                        <img src="" alt="" style="height: 92px">
                        <input type="hidden" name="mobile" value="" id="mobile">
                        {/notempty}
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="notice" class="layui-form-label">
                    通知描述
                </label>
                <div class="layui-input-block" style="width: 50%">
                    <textarea name="notice" id="notice" placeholder="请输入内容"
                        class="layui-textarea">{notempty name="data.notice"}{$data.notice}{/notempty}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="path" class="layui-form-label">
                    指向链接
                </label>
                <div class="layui-input-block" style="width: 50%">
                    {notempty name="data.path"}
                    <input type="text" id="path" name="path" required="" autocomplete="off" class="layui-input"
                        value="{$data.path}">
                    {else /}
                    <input type="text" id="path" name="path" required="" autocomplete="off" class="layui-input">
                    {/notempty}
                </div>
            </div>
            {notempty name="data.id"}
            <input type="hidden" name="id" value="{$data.id}">
            {else /}
            <input type="hidden" name="id" value="">
            {/notempty}
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">保存</button>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="copyright"}
{/block}
{block name="javascript"}
<script>
    layui.use(['form', 'layer'],
        function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //监听提交
            form.on('submit(add)',
                function (data) {
                    $.ajax({
                        url: "{:url('content_notice')}",
                        type: 'POST',
                        data: data.field,
                        'success': function (result) {
                            if (result.status === 1) {
                                layer.msg(result.message, { 'icon': 1, 'time': 500 }, function () {
                                    xadmin.close();
                                    xadmin.father_reload();
                                });
                            } else {
                                layer.msg(result.message, { 'icon': 5, 'time': 1000 });
                            }
                        }
                    }, 'JSON');
                    return false;
                });

        });
</script>
{/block}